<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/10/22
 * Time: 16:32
 */
/*
 * discription:分享model
 * author:胡亮
 * date:2020/10/22
 * **/
class Share_model extends CI_Model
{
    const TBL_Shares = 'mall_share'; //分享表
    /*
     * discription:获取分享列表
     * author:胡亮
     * param:{
     *      offset:从多少条开始往下查
     *      limit:往下查多少条
     *      where:where条件
     * }
     * date:2020/10/22
     * **/
    public function GetShareList($offset,$limit,$where=''){
        if(empty($where)) return $this -> db -> order_by('id desc') -> limit($limit, $offset) -> get(self::TBL_Shares) -> result_array();
        else return  $this -> db ->where($where)->order_by('id desc') -> limit($limit, $offset) -> get(self::TBL_Shares) -> result_array();
    }
    /*
    * discription:获取分享总数
    * author:胡亮
    * param:{
    *      where:where条件
    * }
    * date:2020/10/23
    * **/
    public function GetShareCount($where=''){
        if(empty($where)) return $this->db->count_all_results(self::TBL_Shares);
        else return   $this->db->where($where)->count_all_results(self::TBL_Shares);
    }
    /*
    * discription:获取分享总数
    * author:胡亮
    * param:{
    *      where:where条件
    * }
    * date:2020/10/23
    * **/
    public function GetShareOne($id){
        return   $this->db->where(['id'=>$id])->get(self::TBL_Shares)->row_array();;
    }
}